package geekzpacho.examples.ehcache;

import java.util.List;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

@Component("vehicleDAO")
@Repository
public class VehicleDAO extends AbstractJpaDAO<Vehicle>{
 
	public VehicleDAO(){
		setClassName(Vehicle.class);
	}
	
	
	@Cacheable(value = "vehicleCache")
	public List<Vehicle> getAll() {
		
		List<Vehicle> lstVehicles0 = this.findAll();
		
		return lstVehicles0;
		
	}
 
	@Cacheable(value = "vehicleCache", key = "#id")
	public Vehicle getVehicle(Integer id) {
		
		Vehicle objVehicle = this.findOne(id);
				 
		return objVehicle;
	}
	
	public void insert(Vehicle vehicle) {
		
		this.save(vehicle);
	}
 
}
